package com.bijava.config;

import com.bijava.utils.LoggerFactoryUtil;
import com.dangdang.ddframe.job.executor.ShardingContexts;
import com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener;
import org.slf4j.Logger;
import org.springframework.stereotype.Component;

/**
 * 任务执行监听
 */
@Component
public class TaskJobListener implements ElasticJobListener {
    private static final Logger log = LoggerFactoryUtil.get();

    private long beginTime = 0;

    @Override
    public void beforeJobExecuted(ShardingContexts shardingContexts) {
        beginTime = System.currentTimeMillis();
        //LoggerFactoryUtil.info(log,shardingContexts.getJobName()+"===>开始...");
    }

    @Override
    public void afterJobExecuted(ShardingContexts shardingContexts) {
        long endTime = System.currentTimeMillis();
        //LoggerFactoryUtil.info(log,shardingContexts.getJobName()+"===>结束...[耗时："+(endTime - beginTime)+"]");
    }
}